package com.cy.common.config;

import java.util.Properties;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;

/** 配置kaptcha */
@Configuration
public class KaptchaConfig {
	
	@Bean
    public DefaultKaptcha producer() {
        Properties properties = new Properties();
        properties.put("kaptcha.border", "no");//是否有边框
        properties.put("kaptcha.textproducer.font.color","red");//字体颜色
        properties.put("kaptcha.image.width", "120");//图片宽度
        properties.put("kaptcha..image.height", "50");//图片高度
        properties.put("kaptcha.textproducer.char.string", "ACDEFHIJKLMNOPQRSTUVWXYZ1234567890");//生成使用的字符
        properties.put("kaptcha.textproducer.font.size", "38");//字体大小
        properties.put("kaptcha.noise.color", "black");//干扰颜色
        properties.put("kaptcha.textproducer.char.length", "4");//字符个数
        properties.put("kaptchatextproducer.font.names", "Arial");//字体
        Config config = new Config(properties);
        DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
        defaultKaptcha.setConfig(config);
        return defaultKaptcha;
    }
	
}
